package miage.rest;

import org.restlet.data.Parameter;
import org.restlet.util.Series;

/**
 *
 * @author Schwartz Michaël
 */
public class JeeServer extends Server {

	private static final String PARAMETER_DATABASE_DRIVER = "miage.rest.configuration.database.driverClassName";
	private static final String PARAMETER_DATABASE_USER = "miage.rest.configuration.database.user";
	private static final String PARAMETER_DATABASE_PASSWORD = "miage.rest.configuration.database.password";
	private static final String PARAMETER_DATABASE_URL = "miage.rest.configuration.database.url";
	private static final String PARAMETER_ADMIN_PASSWORD = "miage.rest.configuration.adminPassword";



	@Override
	protected void beforeStart() {
		
		Configuration configuration = new Configuration();
		Series<Parameter> params = getContext().getParameters();

		configuration.setDbDriverClassName(params.getFirstValue(PARAMETER_DATABASE_DRIVER));
		configuration.setDbUser(params.getFirstValue(PARAMETER_DATABASE_USER));
		configuration.setDbPassword(params.getFirstValue(PARAMETER_DATABASE_PASSWORD));
		configuration.setDbUrl(params.getFirstValue(PARAMETER_DATABASE_URL));
		configuration.setAdminPassword(params.getFirstValue(PARAMETER_ADMIN_PASSWORD));

		setConfiguration(configuration);
	}


}
